var search_promotion_top = true;
var RcmdServer_top = "http://174.100.22.78:8888/prototype/suggest/book_suggest.jsp";
var RcmdServer_ff_top = "http://174.100.22.78:8888/prototype/suggest/book_suggest.jsp";
var Td_top;
var Ip_top;
var Ip_del;
var top_position_top;
var left_position_top;
var wi_int_top;
var bak_top="", old_top="";
var table_width_top;
var ke_top;
var suggest_type_top;   // 자동완성 타입 : ""=전체, "B"=책제목, "W"=저자, "P"=출판사
var word_count_top;		// 자동완성 개수
function setDefaultAutoComplete_top_(objTextBox, valTopPosition, valLeftPosition, valTableWidth, valTimeout, valSuggestType, valWordCount, service, objDelText) {
    //var valTableWidth = objTextBox.style.width;
    //alert(objTextBox.clientX)

    Ip_top = objTextBox;
    top_position_top = valTopPosition;
    left_position_top = valLeftPosition;
    table_width_top = valTableWidth;
    wi_int_top = valTimeout;
    bak_top = old_top = Ip_top.value;
    suggest_type_top = valSuggestType;
    word_count_top = valWordCount;
    Ip_del = objDelText;
    
    RcmdServer_top = service+"/search/search_suggest.ododoc";
    RcmdServer_ff_top  = service+"/search/search_suggest.ododoc";
}

var g_ie5_ = 0;
function get_nav_() {
    var ver = navigator.appVersion;
    if (navigator.appName.indexOf("Microsoft") != -1 && ver.indexOf("MSIE 4") == -1 && ver.indexOf("MSIE 3") == -1) {
        if (ver.indexOf("MSIE 5.0") != -1)
            g_ie5_ = 1;
        return 1;
    }
    else if (navigator.appName.indexOf("Netscape") != -1 ) {
        return 2;
    }
    else if (navigator.appName.indexOf("Opera") != -1 ) {
        return 2;
    }
    else {
        return 0;
    }
}

function chk_rt_top_(t_top) {
    //if (t_top != 1) return 0;

    try {
        Td_top=document;
    } catch (e) {
        return 0;
    }

    return 1;
}

var t_top = get_nav_();
var c_top = chk_rt_top_(t_top);
var m_on_top=0, m_now_top=0, s_now_top=0, shl_top=0, a_now_top=0, a_on_top=0, arr_on_top=0, frm_on_top=0;
var cn_use_top = "use_ac";
var B_top="block", I_top="inline", N_top="none", UD_="undefined";
var qs_ac_list_top="", qs_ac_id_top="", qs_q_top="", qs_m_top=0, qs_ac_len_top=0, qs_ac_cnt_list_top="",
qs_p_cnt_top="", qs_s_cnt_top=""
//var acuse_top = getCookie_(cn_use_top);
//if (acuse_top == "") acuse_top = 1;
var acuse_top = 1;
var cc_top = new Object();
if ((t_top == 1 || t_top == 2) && c_top == 1) {
    function wd_top_() {
        var a = top_position_top;
        var b = left_position_top;

        //document.getElementById("ac_body_top_").style.top = a + "px";
        //document.getElementById("ac_body_top_").style.left = b + "px";
        //document.getElementById("ac_table_").style.width = table_width_top + "px";

        if (acuse_top == 1) Ip_top.autocomplete = "off";
        else if (acuse_top == 0) Ip_top.autocomplete = "on";

        Ip_top.onclick = req_ipc_top_;
        Ip_top.onblur = dis_p_top_;
        Td_top.onclick = dis_p_top_;
    }

    var dnc_top_ = 0;
    function req_ipc_top_() {
        dnc_top_ = 1;
        frm_on_top = 0;
        req_ac2_top_(1);
    }

    function dis_p_top_() {
        if (dnc_top_) {
            dnc_top_ = 0;
            return;
        }
        if (arr_on_top) {
            return;
        }
        if (frm_on_top) {
            return;
        }

        alw = 0;
        ac_hide_top_();
    }

    function req_ac2_top_(me) {
        if (Ip_top.value == "" || acuse_top==0 ) return;
        if (a_on_top && dnc_top_) {
            ac_hide_top_();
            return;
        }

        var o = get_cc_top_(me);
        if (o && o[1][0] != "") ac_show_top_(o[0], o[1], o[2], me);
        else reqAC_top_(me);
    }

    var _req_top_ = null;
    function get_req_top_()
    {
        if (window.ActiveXObject) {
            try {
                return new ActiveXObject("Msxml2.XMLHTTP");
            } catch (e) {
                try {
                    return new ActiveXObject("Microsoft.XMLHTTP");
                } catch (e2) {
                    return null;
                }
            }
        } else if (window.XMLHttpRequest) {
            //Win Mac Linux m1,f1,o8 Mac s1 Linux k3
            return new XMLHttpRequest();
        } else {
            return null;
        }

    }

    function showAC_top_() {         
        //if (_req_top_.readyState == 4 && _req_top_.responseText && _req_top_.status == 200) {
            //alert(_req_top_.responseText);

            try {
                eval(_req_top_.responseText);
            } catch(e) {
                var qs_q_top = '';
                var qs_m_top = '1';
                var qs_ac_id_top = '1';
                var qs_ac_list_top = new Array(''); 
            }
            alert(_req_top_.responseText);
            set_cc_top_(qs_q_top, qs_ac_list_top, qs_m_top);
            ac_show_top_(qs_q_top, qs_ac_list_top, qs_ac_id_top, qs_m_top);
        //}
    }

    function showResponse_top(oj) {      
        //if (_req_top_.readyState == 4 && _req_top_.responseText && _req_top_.status == 200) {
            //alert(_req_top_.responseText);
            try {
                var qs_q_ = oj.qs_q_;
                var qs_m_ = oj.qs_m_;
                var qs_p_cnt = oj.qs_p_cnt;
				var qs_s_cnt = oj.qs_s_cnt;

                eval(oj.responseText);
            } catch(e) {
                var qs_q_top = '';
                var qs_m_top = '1';
                var qs_ac_id_top = '1';
                var qs_ac_list_top = new Array(''); 
            }
            set_cc_top_(qs_q_, qs_ac_list_, qs_m_);
			ac_show_top_(qs_q_, qs_ac_list_, qs_ac_id_, qs_m_ ,qs_p_cnt, qs_s_cnt);
        //}
    }

    function sendRequest_top(callback, url, data, method)
    {
        var oj = get_req_top_();

        _req_top_ = oj;
        if (oj == null) return null;

        var ua = navigator.userAgent;
        var safari  = ua.indexOf("Safari") != -1;
        var konqueror   = ua.indexOf("Konqueror") != -1;
        var mozes   = ((a=navigator.userAgent.split("Gecko/")[1] ) ?a.split(" ")[0]:0) >= 20011128;

        if (window.opera || safari || mozes) {
            oj.onload = function () { callback(oj) };
        } else {
            oj.onreadystatechange = function() 
            {
                if (oj.readyState == 4) {
                    callback(oj);
                }
            }
        }

        /*
         * IE가 아닐경우 POST로 사용한다. 
         */
        
        if (window.opera || safari || mozes) {
            method = "POST";
            oj.open("POST", RcmdServer_ff_top);
            oj.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;charset=UTF-8");
            oj.send(data);
        }
        else {
            method = "POST";
            oj.open("POST", RcmdServer_ff_top);
            oj.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;charset=UTF-8");
            oj.send(data);
            /*  heon
            url = url + "?" + data;
             //alert( 'sendRequest_top url'+url);
            oj.open(method, url);
            oj.send(null);
            */
        }
    }

    function reqAC_top_(me) {
        var sv;
        var stripped = "";

        ke_top = trim_space_top_(Ip_top.value, me);
        ke_top = ke_top.replace(/ /g, " ");
        ke_top = ke_top.replace(/\\/g, "");
        // ke_top = ke_top.replace(/\'/g, "");  // 2009.08.13 KYPARK : '를 자동완성 서버로 넘기기 위해서 막음
        ke_top = ke_top.replace(/&/g, "");
        ke_top = ke_top.replace(/|/g, "");
        ke_top = ke_top.replace(/ or /g, "");
        ke_top = ke_top.replace(/ and /g, "");
        ke_top = ke_top.replace(/ OR /g, "");
        ke_top = ke_top.replace(/ AND /g, "");
        ke_top = ke_top.replace(/-/g, "");
        ke_top = ke_top.replace(/ not /g, "");
        ke_top = ke_top.replace(/%/g, "%25");   // 2009.08.14 KYPARK : %를 자동완성 서버로 넘기기 위해서 추가

        if ((ke_top == "") || (ke_top == "or") || (ke_top == "and") || (ke_top=="not")) {
            ac_hide_top_();
            return;
        }

        var lastChar = ke_top.charAt(ke_top.length-1);

        //sv = RcmdServer_top + ke_top;
        sv = RcmdServer_top + ke_top;
        //heon 수정
        ke_top = "suggestType=" + suggest_type_top + "&wordCount=" + word_count_top + "&query=" + ke_top;
        //ke_top = "suggestType=" + suggest_type_top + "&wordCount=" + word_count_top + "&query=" + encodeURIComponent(ke_top);
        sendRequest_top(showResponse_top, RcmdServer_top, ke_top, "GET");
    }

	function ac_show_top_(aq, al, ai, am, p_cnt, s_cnt) {
        if (aq && aq != "" && aq != trim_space_top_(Ip_top.value, am))
            return;

        qs_q_top = aq;
        qs_m_top = am;
        qs_ac_list_top = al;
        qs_ac_id_top = ai;
        qs_ac_len_top = qs_ac_list_.length;
		qs_p_cnt_top = p_cnt;
        qs_s_cnt_top = s_cnt;

        var h = (qs_ac_len_top > 9) ? 9 : qs_ac_len_top;
        h = h * 20;

        print_ac_top_();

        if (qs_ac_list_top[0] == "" && (qs_m_top == 1 || qs_m_top == 2)) {
            qs_ac_len_top = 1;
            h = 20;
            if (qs_ac_list_top[0] == "") h = h+20;
        }
        //document.getElementById("scrol_top_").style.height = h;

        if (qs_ac_len_top) {
            h += 41;
            a_on_top = 1;
        } else {
            a_on_top = 0;
        }
        document.getElementById("ac_body_top_").width = 155;
        //document.getElementById("ac_body_top_").width = table_width_top+4;
        //document.getElementById("ac_body_top_").height = h;
        //document.getElementById("ac_table_").style.width = table_width_top;

        document.getElementById("ac_body_top_").style.display = B_top;
        //var IfrRef = document.getElementById('DivShim');
        //IfrRef.style.display = B_top;

        if (a_on_top) {
            set_acpos_top_(0);
            document.getElementById("scrol_top_").scrollTop = 0;
            Ip_top.onkeydown = ackhl_top_;
        }
    }

    function set_acpos_top_(v) {
        a_now_top = v;
        setTimeout('set_ahl_();', 10);
    }

    function set_ahl_() {
        var o1, o2;

        if (!a_on_top) return;
        for (i=0;  i<qs_ac_len_top; i++) {
            o1 = eval("document.getElementById('ac" + (i+1) + "_')");

            // 2012.02.14 add by seung-hoon : 예외처리 
            if(!o1) return; 
            //0921
            //if ((i+1) == a_now_top) o1.style.backgroundColor = "#DDECCC";
            //else o1.style.backgroundColor = "";
            var cnt1 = a_now_top;
            var cnt2 = i+1;
        	if ((i+1) == a_now_top){
                o1.className = "over";
            }
            else {
            	o1.className = "end";
            }

        }
    }

    var max_row_ = 4;
// heon
//  function ackhl_top_() {
//      var e = window.event;
function ackhl_top_(e) {
         var e= e || window.event ;
        var o1, o2, o3;
        if (e.keyCode == 39) {
            req_ac2_top_(1);
        }
        
        if (e.keyCode == 40 || (e.keyCode == 9 && !e.shiftKey)) {
            if (m_on_top) return;
            if (!a_on_top) {
                req_ac2_top_(1);
                return;
            }
            if (a_now_top < qs_ac_len_top) {
                if (a_now_top == 0) bak_top = Ip_top.value;
                a_now_top++;
                if (a_now_top > max_row_){
                    document.getElementById("scrol_top_").scrollTop = parseInt((a_now_top-1)/max_row_)*max_row_*20;
                }
                o1 = eval("document.getElementById('ac" + a_now_top + "_')");
                o2 = eval("document.getElementById('acq" + a_now_top + "_')");
                // heon html 특수문자 처리
                old_top = Ip_top.value = o2.innerHTML.replace("&amp;","&"); 
				//2011.10.20 add by seung-hoon
				//o3 = eval("document.getElementById('acq" + a_now_top + "_img_')").innerHTML;
				//img_thumb_(o3);
                //old_top = Ip_top.value = o2.textContent;
                Ip_top.focus();
                set_ahl_();
                e.returnValue = false;
            }
        }
        if (a_on_top && (e.keyCode == 38 || (e.keyCode == 9 && e.shiftKey))) {
            if (!a_on_top) return;
            if (a_now_top <= 1) {
                ac_hide_top_();
                // heon html 특수문자 처리
                //old_top = Ip_top.value = bak_top;
                
                // 2012.02.14 add by seung-hoon : 예외처리 
                if(!o2) return;
                old_top = Ip_top.value = o2.innerHTML.replace("&amp;","&");
            }
            else {
                a_now_top--;
                if ((qs_ac_len_top-a_now_top)+1 > max_row_) document.getElementById("scrol_top_").scrollTop = (qs_ac_len_top-(parseInt((qs_ac_len_top-a_now_top)/max_row_)+1)*4)*20;
                o1 = eval("document.getElementById('ac" + a_now_top + "_')");
                o2 = eval("document.getElementById('acq" + a_now_top + "_')");

                //old_top = Ip_top.value = o2.innerHTML;
                // 2012.02.14 add by seung-hoon : 예외처리 
                if(!o2) return;
                old_top = Ip_top.value = o2.innerHTML.replace("&amp;","&");
				//2011.10.20 add by seung-hoon
				//o3 = eval("document.getElementById('acq" + a_now_top + "_img_')").innerHTML;
				//img_thumb_(o3);

                Ip_top.focus();
                set_ahl_();
                e.returnValue = false;
            }
        }
    }

    function print_ac_top_() {
        
    	if (qs_ac_len_top == 0) {
    		$('ul.list_book').attr("style", "display:none");
    		$('ul.list_writer').attr("style", "display:none");
    	}
    	else {
    		if (qs_ac_list_top[0] == "") {
                //document.getElementById("scrol_top_").innerHTML = get_ac0_top_();
                $("#scrol_top_").html(get_ac0_top_()); 
            }
            else {
                //document.getElementById("scrol_top_").innerHTML = get_aclist_top_(); // 첫단어
            	//document.getElementById("scrol_top_s_").innerHTML = get_aclist_s_top_(); // 끝단어
                $("#scrol_top_").html(get_aclist_top_()); // 첫단어
                $("#scrol_top_s_").html(get_aclist_s_top_()); // 첫단어
                $('ul.list_book').attr("style", "display:;");
        		$('ul.list_writer').attr("style", "display:;");
            }
            //document.getElementById("ac_body_top_").style.display = B_top;
            $('#ac_body_top_').attr("style", "display:"+B_top);
            //var IfrRef = document.getElementById('DivShim');
            //IfrRef.style.display = B_top;
            //setTimeout('set_ahl_();', 10);
            setTimeout('set_ahl_();', 30);
            if (qs_p_cnt_top == 0) $('ul.list_book').attr("style", "display:none");
            if (qs_s_cnt_top == 0) $('ul.list_writer').attr("style", "display:none");
    	}
    	
        /*
    	if (qs_ac_list_top[0] == "") {
            document.getElementById("scrol_top_").innerHTML = get_ac0_top_();
        }
        else {
            document.getElementById("scrol_top_").innerHTML = get_aclist_top_(); // 첫단어
            document.getElementById("scrol_top_s_").innerHTML = get_aclist_s_top_(); // 끝단어
        }
        document.getElementById("ac_body_top_").style.display = B_top;
        //var IfrRef = document.getElementById('DivShim');
        //IfrRef.style.display = B_top;
        //setTimeout('set_ahl_();', 10);
        setTimeout('set_ahl_();', 30);
        */
    }

	function get_aclist_top_() {
         var d="",ds="",l=0,s="",type="",id="",img="",writer="" ;
         var dscnt = 0;
         var s_cnt, e_cnt =0;
         if (qs_ac_list_top[0] != "") {
             
             if( qs_p_cnt_top > 0) {
				 //s += "<dl style=\"margin:0;padding:0\">";
                 //s += "<dt>첫단어</dt>" ;
                 s_cnt = 0;
                 e_cnt = qs_p_cnt_top;
                 for (var i=0; i<e_cnt; i++) {
                     //ds = d = qs_ac_list_top[i];
                     var s_keyworkds = qs_ac_list_top[i].split('^');
                     ds = d = s_keyworkds[0];
                     type = s_keyworkds[1];
                     id = s_keyworkds[2];
                     img = s_keyworkds[3];
                     writer = s_keyworkds[4];
                     //dscnt = qs_ac_cnt_list_top[i];
                     l = js_strlen_top_(d);
                     if (l > 20) ds = js_substring_top_(d, 0, 20) + "..." ;
                     //ds = js_highlight_top(ds, qs_q_top, qs_q_top, 0);
                     ds = js_highlight(qs_q_top, ds);
                     if(writer != null){
                    	 writer = js_highlight_top(writer, qs_q_top, qs_q_top, 0);
                         ds = ds + " | " + writer;
                     }
					 //2011.10.21 modify by seung-hoon
					 //ds = js_highlight(qs_q_top, ds);
                     //s += "<li style='display:;' id='ac" + (i+1) + "_' onmouseover=\"set_acpos_top_('" + (i+1) + "'); img_thumb_('" + img + "');\" onmouseout=\"set_acpos_top_(0); \" onclick=\"set_acinput_top_('" + d + "');return input_check();\" style=\"this.style.backgroundColor=''\">" ;
                     s += "<li style='display:;' id='ac" + (i+1) + "_' onmouseover=\"set_acpos_top_('" + (i+1) + "'); \" onmouseout=\"set_acpos_top_(0); \" style=\"this.style.backgroundColor=''\">" ;
                     s += "<a href=\"#\" onclick=\"set_acinput_top_(); return input_check();\">" + ds + "</a></li>" ;
					 s += "<span id='acq" + (i+1) + "_' style='display:none; width:0px; height:0px;'>" +  d.replace("&amp;", "&") + "</span>" ;
					 //2011.10.20 add by seung-hoon
					 //s += "<span id='acq" + (i+1) + "_img_' style='display:none; width:0px; height:0px;'>" +  img + "</span>" ;

                     var test =  d.replace("&amp;", "&");
                     //s += "</tr></a>" ;
                 }
				 //s += "</dl>";
             }
			 //if(qs_s_cnt_top>2 && qs_p_cnt_top>2) s += "<li id=more><a href='javascript:displayAutoMore(\"suf\")'>끝단어 더보기</a></li>";

         }
         return s ;
     }
	
	function get_aclist_s_top_() {
        var d="",ds="",l=0,s="",type="",id="",img="",writer="" ;
        var dscnt = 0;
        var s_cnt, e_cnt =0;
        if (qs_ac_list_top[0] != "") {
       
        	if( qs_p_cnt_top > 0) {
				//s += "<dl style=\"margin:0;padding:0\">";
                //s += "<dt>첫단어</dt>" ;
                s_cnt = 0;
                e_cnt = qs_p_cnt_top;
        	}
        	
            if( qs_s_cnt_top > 0) {
                //s += "<dt>끝단어</dt>" ;
                s_cnt = e_cnt;
                e_cnt += qs_s_cnt_top;
                var j;
                if(qs_p_cnt_top > 2) j=0;
                else j=-8;
                for (var i=s_cnt; i<e_cnt; i++, j++) {
                    //ds = d = qs_ac_list_top[i];
                    var s_keyworkds = qs_ac_list_top[i].split('^');
                    ds = d = s_keyworkds[0];
                    type = s_keyworkds[1];
                    id = s_keyworkds[2];
                    img = s_keyworkds[3];
                    writer = s_keyworkds[4];
                    //dscnt = qs_ac_cnt_list_top[i];
                    l = js_strlen_top_(d);
                    if (l > 20) ds = js_substring_top_(d, 0, 20) + "..." ;
                    ds = js_highlight_top(ds, qs_q_top, qs_q_top, 1);
                    if(writer != null){
                   	 writer = js_highlight_top(writer, qs_q_top, qs_q_top, 0);
                        ds = ds + " | " + writer;
                    }
                    
					 //2011.10.21 modify by seung-hoon
					 //ds = js_highlight(qs_q_top, ds);

					 if(j>1){
						 //s += "<li style='display:none;' id='ac" + (i+1) + "_' onmouseover=\"set_acpos_top_('" + (i+1) + "'); img_thumb_('" + img + "');\" onmouseout=\"set_acpos_top_(0); \" onclick=\"set_acinput_top_('" + d + "');return input_check();\" style=\"this.style.backgroundColor=''\">" ;
						 s += "<li style='display:none;' id='ac" + (i+1) + "_' onmouseover=\"set_acpos_top_('" + (i+1) + "'); \" onmouseout=\"set_acpos_top_(0); \" style=\"this.style.backgroundColor=''\">" ;
					 }else{
						 //s += "<li style='display:;' id='ac" + (i+1) + "_' onmouseover=\"set_acpos_top_('" + (i+1) + "'); img_thumb_('" + img + "');\" onmouseout=\"set_acpos_top_(0); \" onclick=\"set_acinput_top_('" + d + "');return input_check();\" style=\"this.style.backgroundColor=''\">" ;
						 s += "<li style='display:;' id='ac" + (i+1) + "_' onmouseover=\"set_acpos_top_('" + (i+1) + "'); \" onmouseout=\"set_acpos_top_(0); \" style=\"this.style.backgroundColor=''\">" ;
					 }
					 s += "<a href=\"#\" onclick=\"set_acinput_top_(); return input_check();\">" + ds + "</a></li>" ;
					 s += "<span id='acq" + (i+1) + "_' style='display:none; width:0px; height:0px;'>" + d.replace("&amp;", "&") + "</span>" ;
					 //2011.10.20 add by seung-hoon
					 //s += "<span id='acq" + (i+1) + "_img_' style='display:none; width:0px; height:0px;'>" +  img + "</span>" ;
                    //s += "</tr></a>" ;
                   
                }
            }
			
            if(qs_s_cnt_top>2 && qs_p_cnt_top>2) s += "<dt id=more><a href='javascript:displayAutoMore(\"suf\")'><em class=\"t_warn\">끝단어 더보기</em></a></dt>";

        }
        return s ;
    }

	 function displayAutoMore(type) {

		if(type == 'suf')
		{
			for(var i=2; i<qs_p_cnt_top; i++)
				document.getElementById("ac"+(i+1)+"_").style.display = 'none';
			for(var j=qs_p_cnt_top+2; j<qs_p_cnt_top+qs_s_cnt_top; j++)
				document.getElementById("ac"+(j+1)+"_").style.display = '';

			document.getElementById("more").innerHTML = "<a href='javascript:displayAutoMore(\"pre\")'><em class=\"t_warn\">첫단어 더보기</em></a>";
		}
		else {
			for(var i=2; i<qs_p_cnt_top; i++)
				document.getElementById("ac"+(i+1)+"_").style.display = '';
			for(var j=qs_p_cnt_top+2; j<qs_p_cnt_top+qs_s_cnt_top; j++)
				document.getElementById("ac"+(j+1)+"_").style.display = 'none';

			document.getElementById("more").innerHTML = "<a href='javascript:displayAutoMore(\"suf\")'><em class=\"t_warn\">끝단어 더보기</em></a>";
		}
	 }

	 //2011.10.20 add by seung-hoon
	 function img_thumb_(path) {
		//var img_home = "http://bookthumb.phinf.naver.net";
		var img_home = "http://112.216.59.131:8082/grim/";
		var imgDest = document.getElementById("img_thumb");
		//기본이미지 : 이미지 준비중
		var imgSrc = "http://i1.daumcdn.net/img-contents/book/2010/110x160_v2.gif";
		//이미지 확인
		var img_path_last = path.lastIndexOf('.');
		if(img_path_last != -1) imgSrc = img_home + path;
		document.getElementById("img_wrap").style.display = "block";
		imgDest.setAttribute("src", imgSrc);
	 }
 
    function js_highlight_top(s, d, eq, is_suf) { 
        var ret = ""; 

        if (!is_suf) { 
            ret = js_makehigh_pre_top(s, d); 
            //if (ret == "") ret = js_makehigh_pre_top(s, r); // revised query
            if (ret == "") ret = js_makehigh_pre_top(s, eq); 
        } else { 
            ret = js_makehigh_suf_top(s, d); 
            //if (ret == "") ret = js_makehigh_suf_top(s, r); // revised query
            if (ret == "") ret = js_makehigh_suf_top(s, eq); 
        } 

        if (ret == "") return s;
        else return ret; 
    } 

    function js_makehigh_pre_top(s, t) { 
        var d = ""; 
        var s1 = s.replace(/ /g, ""); 
        var t1 = t.replace(/ /g, ""); 

        s1 = s1.toLowerCase();  // 2009.09.14 KYPARK : 대소문자 무시
        t1 = t1.toLowerCase(); 
        if (t1 == s1.substring(0, t1.length)) { 
            //heon 수정
            //d = "<font color='red'>"; 
            d = "<em class=\"t_warn\">"; 
            for (var i=0, j=0; j < t1.length; i++) { 
                if (s.substring(i, i+1) != " ") j++; 
                d += s.substring(i, i+1); 
            } 
            //d += "</font>"+s.substring(i, s.length); 
            d += "</em>"+s.substring(i, s.length); 
        }

        return d; 
    } 

    function js_makehigh_suf_top(s, t) { 
        var d = ""; 
        var s1 = s.replace(/ /g, ""); 
        var t1 = t.replace(/ /g, ""); 

        s1 = s1.toLowerCase();  // 2009.09.14 KYPARK : 대소문자 무시
        t1 = t1.toLowerCase(); 
        if (t1 == s1.substring(s1.length-t1.length)) { 
            for (var i=0, j=0; j < s1.length-t1.length; i++) { 
                if (s.substring(i, i+1) != " ") j++; 
                d += s.substring(i, i+1);
            } 
            //heon 수정   
            //d+="<font color='red'>"; 
            d =  s.substring(0, i) + "<em class=\"t_warn\">"; 
            for (var k=i, l=0; l < t1.length; k++) { 
                if (s.substring(k, k+1) != " ") l++; 
                d += s.substring(k, k+1);
            }
            //d += "</font>"; 
            d +="</em>"; 
        }

        return d; 
    } 

	//2011.10.21 add by seung-hoon : 자동완성 하이라이팅
	function js_highlight(query, str) {    
		var d = "";
		var query1 = query.replace(/ /g, ""); 
        var str1 = str.replace(/ /g, ""); 

		if (str1 != "") {
			var regObj = new RegExp('('+query1+')', 'ig');
			regObj.exec(str1);
			var findStr = RegExp.$1;

			var retStr = str;
			
			for (var i=0; i<findStr.length; i++)
			{ 

				retStr = retStr.replace(new RegExp('('+findStr.charAt(i)+')', "ig"), "$"+findStr.charAt(i)+"^");
			}

			retStr = retStr.replaceAll("$","<em class=\"t_warn\">").replaceAll("^","</em>");
			return retStr;
		}

			
/*
		if (str != "") {
			var regObj = new RegExp('('+query+')', 'ig');
			regObj.exec(str);
			var findStr = RegExp.$1;
			var regObjRep = new RegExp('('+query+')', 'ig');
			var retStr = str.replace(regObjRep, "<em class=\"t_warn\">"+findStr+"</em>"); 
			
			return retStr;
		}
*/
	}

/*
    function set_acinput_top_(v) {
        
        if (!a_on_top) return;
        //var o = eval("document.getElementById('ac" + a_now_top + "_');");
        //alert(o.outerText);

        // 2009.07.23 KYPARK : value가 아니라 qs_ac_list의 index를 받아서 셋팅하도록 수정
        //old_top = Ip_top.value = v;
        old_top = Ip_top.value = qs_ac_list_top[v];
        Ip_top.focus();
        ac_hide_top_();
    }
*/
	/*
    function set_acinput_top_(v) {
             if (!a_on_top) return ;
             //var o = eval("document.getElementById('ac" + a_now_top + "_');") ;
             //alert(o.outerText);
             old_top = Ip_top.value = v ;
             Ip_top.focus() ;
             ac_hide_top_() ;
         }
    */
    function set_acinput_top_() {
        if (!a_on_top) return ;
        var o = eval("document.getElementById('acq" + a_now_top + "_');") ;
        //alert(o.outerText);
        old_top = Ip_top.value = o.outerText ;
        Ip_top.focus() ;
        ac_hide_top_() ;
    }

    function get_ac0_top_() {
        var s="", ment="";
        var ac0_table_width = table_width_top-7;

		if (qs_m_top==1) ment = "해당 단어로 시작하는 단어가 없습니다";
        else if (qs_m_top==2) ment = "해당 단어로 끝나는 단어가 없습니다";

//      s += "<table style='width:" + ac0_table_width + ";' border=0 cellspacing=0 cellpadding=0>";
//      s += "<tr id=ac1_ onmouseover=\"set_acpos_top_(1); \" onmouseout=\"set_acpos_top_(0);\" style=\"backgroundColor=''\">";
//      s += "<td height=18 align=left  valign='top'>ㆍ<font color=#000000>" + ment + "</td></tr>";
//      s += "</table>";
//        s += "<dd class='end' id='ac1_'>" + ment + "</dt>" ;
//        s += "<span id=acq1_ style='display:none'>" + old_top + "</span>";
        

        return s;
    }

    function js_strlen_top_(s) {
        var i, l=0;

        for (i=0; i < s.length; i++)
            if (s.charCodeAt(i) > 127) l+=2;
            else l++;

        return l;
    }

    function js_substring_top_(s, start, len) {
        var i, l=0, d="";

        for (i=start; i < s.length && l < len; i++) {
            if (s.charCodeAt(i) > 127) l += 2;
            else l++;
            d += s.substr(i, 1);
        }

        return d;
    }

    function trim_space_top_(ke_top, me) {
        if (me != 2) {
            ke_top = ke_top.replace(/^ +/g, "");
            ke_top = ke_top.replace(/ +$/g, " ");
        } else {
            ke_top = ke_top.replace(/^ +/g, " ");
            ke_top = ke_top.replace(/ +$/g, "");
        }
        ke_top = ke_top.replace(/ +$/g, " ");

        return ke_top;
    }

    function get_cc_top_(me) {
        var ke_top = trim_space_top_(Ip_top.value, me) + me;

        return typeof(cc_top[ke_top])==UD_ ? null : cc_top[ke_top];
    }

    function set_cc_top_(aq, al, ai, me) {
        cc_top[aq+me] = new Array(aq, al, ai);
    }

    function ac_hide_top_() {
        if (document.getElementById("sch_layer").style.display == N_top) return;
        document.getElementById("sch_layer").style.display = N_top;
        //var IfrRef = document.getElementById('DivShim');
        //IfrRef.style.display = N_top;
        a_on_top = a_now_top = 0;
		//2011.10.20 add by seung-hoon
		//document.getElementById("img_wrap").style.display = N_top;
    }

    function wi_top_() {
        if (acuse_top == 0) return;
        if (m_on_top) {
            setTimeout("wi_top_()", wi_int_top);
            return;
        }

        var now = Ip_top.value;
        if (now == "") {
        	Ip_del.style.display = N_top;
        }
        if (now == "" && now != old_top) ac_hide_top_();
        if (now != "" && now != old_top && keystatus_top_!=1) {
        	Ip_del.style.display = B_top;
            var o=null, me=1;
            o = get_cc_top_(me);
            if (o && o[1][0] != "") ac_show_top_(o[0], o[1], o[2], me);
            else reqAC_top_(me);
        }

        old_top = now;
        setTimeout("wi_top_()", wi_int_top);
    }

    function set_mouseon_top_(f) {
        if (f == 1) arr_on_top = 1;
        else if (f == 2) frm_on_top = 1;
    }

    function set_mouseoff_top_(f) {
        if (f == 1) arr_on_top = 0;
        else if (f == 2) frm_on_top = 0;
    }

    function req_pf_top_() {
        frm_on_top = 1;
        req_ac2_top_(1);
        Ip_top.focus();
        cursor_end_top_();
    }

    function req_sf_top_() {
        frm_on_top = 1;
        req_ac2_top_(2);
        Ip_top.focus();
        cursor_end_top_();
    }

    function cursor_end_top_() {
        if (t_top == 1 && c_top == 1) {
            var rng = Ip_top.createTextRange();

            if (rng != null) {
                rng.move("textedit");
                rng.select();
            }
        }
    }
}

var keystatus_top_ = 1;
function setTextBox_top_(evt) {
    var textbox = Ip_top;
    var _event;

    switch (getNavigatorType_()) {
        case 1 : // IE
            _event = window.event;
            nodeName = _event.srcElement.nodeName;
            break;
        case 2 : // Netscape
            _event = evt;
            //nodeName = _event.target.nodeName;
            //nodeName = _event.target.nodeName;
            nodeName = _event.nodeName;
            break;
        default :
            nodeName = "None";
            break;
    }

    key = _event.keyCode;
    if (keystatus_top_ == 1 && key != 13) {
        //textbox.value = "";
        keystatus_top_ = 2;
    }
}

function getNavigatorType_() {
    
    if (navigator.appName == "Microsoft Internet Explorer")
        return 1;
    else if (navigator.appName == "Netscape" || navigator.appName == "Opera")
        return 2;
    else
        return 0;
}

function search_promo_top_off() {
    search_promotion_top = false;
}

function getBrws() {
    var ua = navigator.userAgent;
    var safari  = ua.indexOf("Safari") != -1;
    var konqueror   = ua.indexOf("Konqueror") != -1;
    var mozes   = ((a=navigator.userAgent.split("Gecko/")[1]) ?a.split(" ")[0]:0) >= 20011128;

    if (window.opera || safari || mozes)
        return "NI";
    else
        return "IE";                            
}

/*
function get_re_search2 () {
    //searchTop ();
    //sechfrmsubmit();
}
*/
